package jdbc.test;

import cn.myschool.java79.util.DBUtil;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

/**
 * @author oldliu
 * @since 1.0
 */
public class DBCount {
    public static void main(String[] args) {
        //统计多少个学生
        Connection con = null;
        Statement st = null;
        String sql="select count(stuno) as c from s_student ";
        ResultSet re=null;
        try {
            con = DBUtil.getConnection();
            st = con.createStatement();
            re = st.executeQuery(sql);
            if (re.next()){
                System.out.println(re.getLong(1));
            }
        } catch (SQLException e) {
            e.printStackTrace();
        }finally {
            DBUtil.close(re,st,con);


        }
    }
}
